<template>
  <div>
    <!-- 头部 -->
    <div class="dark-top">
      <a @click="goback" class="page-back"><div></div></a>
      <div class="top-title">
        <div v-if="orderInfo.status == 2">配送完成</div>
        <div v-else>正在配送</div>
      </div>
    </div>
    <!-- 与绝对定位的高度一样 -->
    <div style="height: 12.5rem;"></div>
    <!-- 订单信息 -->
    <div class="dark-order">
      <div class="dark-order-div">
        订单编号<span class="order-span">{{ orderInfo.number }}</span>
      </div>
      <div class="dark-order-div">
        创建时间<span class="order-span">{{ orderInfo.create_time }}</span>
      </div>
      <div class="order-div2">收货人：{{ orderInfo.username }}</div>
      <div class="order-div2">收货地址：{{ orderInfo.user_site }}</div>
      <div class="order-div2">收货人电话：{{ orderInfo.user_tel }}</div>
    </div>
    <!-- 与绝对定位的高度一样 -->
    <div style="height: 6.5rem"></div>
    <!-- 订单详情列表 -->
    <div class="dark-order-list">
      <div class="order-list-box" v-for="item in orderData" :key="item.id">
        <div class="box_left">
          <!-- 商品图 -->
          <div
            class="order-picture"
            :style="{ backgroundImage: 'url(' + item.picture + ')' }"
          ></div>
        </div>
        <!-- 商品内容 -->
        <div class="box_right">
          <div class="order-right-contend">
            {{ item.headline }}
          </div>
          <div class="order-right-gauge">规格：{{ item.gauge }}</div>
          <div class="order-right-price">￥{{ item.price }}</div>
        </div>
      </div>
    </div>
    <!-- 底部按钮 -->
    <div class="dark-buttom" @click="goShippingPhotos">上传配送完成凭证</div>
  </div>
</template>

<script>
import { Indicator } from "mint-ui";
import { Toast } from "mint-ui";
export default {
  data() {
    return {
      psOrder: "",
      orderInfo: [],
      orderData: []
    };
  },
  created() {
    this.psOrder = this.$route.params.ps_oid;
    this.selShippingDetails();
  },
  methods: {
    goback() {
      this.$router.go(-1);
    },
    //到 配送上传图片
    goShippingPhotos() {
      this.$router.push({
        name: "ShippingPhotos"
      });
    },
    //配送详情页获取数据
    selShippingDetails() {
      if (this.psOrder == null) {
        this.psOrder = localStorage.ps_oid;
      }
      //console.log(this.psOrder);
      Indicator.open({ spinnerType: "fading-circle" });
      let me = this;
      this.$axios
        .post(
          "/api/home/shippingDetails",
          { ps_oid: this.psOrder },
          { emulateJSON: true }
        )
        .then(kun => {
          console.log(kun);
          Indicator.close();
          if (kun.code == 200) {
            me.orderData = kun.data;
            me.orderInfo = kun.msg;
          } else {
            Toast(kun.msg);
          }
        })
        .catch(function(error) {
          console.log(error);
        });
    }
  }
};
</script>

<style lang="scss" scoped>
p {
  margin: 0;
  padding: 0;
}
.box_left {
  float: left;
}
.box_right {
  float: right;
}
//头部
.dark-top {
  width: 100%;
  height: 12.5rem;
  color: #1a1a1a;
  position: relative;
  background-image: url(../../assets/shop/bg_order.png);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  overflow: hidden;
  position: fixed;
  top: 0;
  z-index: 9999;
  .page-back {
    width: 0.5625rem;
    height: 0.9375rem;
    text-decoration: none;
    color: #1a1a1a;
    display: inline-block;
    position: absolute;
    left: 0.9375rem;
    top: 2.4375rem;

    :first-child {
      width: 100%;
      height: 100%;
      background-image: url(../../assets/login/return-white.png);
      background-repeat: no-repeat;
      background-size: contain;
      background-position: center;
      overflow: hidden;
    }
  }
  .top-title {
    text-align: center;
    font-size: 1.5rem;
    color: #fefefe;
    margin-top: 5.25rem;
  }
}

//订单信息
.dark-order {
  width: 21.5625rem;
  height: 8.25rem;
  box-shadow: 0 0 0 0.0625rem rgba(0, 0, 0, 0.05);
  position: fixed;
  top: 9.4375rem;
  left: 50%;
  z-index: 9999;
  -ms-transform: translateX(-50%) translateY(0); /* IE 9 */
  -moz-transform: translateX(-50%) translateY(0); /* Firefox */
  -webkit-transform: translateX(-50%) translateY(0); /* Safari 和 Chrome */
  -o-transform: translateX(-50%) translateY(0); /* Opera */
  border-radius: 0.625rem;
  background-color: #ffffffff;

  .dark-order-div {
    margin: 0.625rem 0 0 0.9375rem;
    font-size: 0.875rem;
    color: #333333;
    .order-span {
      margin-left: 1.9375rem;
    }
  }
  .order-div2 {
    margin: 0.3125rem 0 0 0.9375rem;
    font-size: 0.75rem;
    color: #9a9a9a;
  }
}
//订单详情列表
.dark-order-list {
  width: 21.5625rem;
  margin: 0 auto;
  .order-list-box {
    width: 21.5625rem;
    height: 10.0625rem;
    border-radius: 0.625rem;
    box-shadow: 0 0 0 0.0625rem rgba(0, 0, 0, 0.05);
    margin-bottom: 0.625rem;
    //商品图
    .order-picture {
      width: 5.625rem;
      height: 8.125rem;
      margin: 0.875rem 0 0 0.875rem;
      background-image: url(../../assets/shop/spimg.png);
      background-repeat: no-repeat;
      background-size: contain;
      background-position: center;
      overflow: hidden;
    }
    //商品内容
    .box_right {
      width: 216px;
      height: 8.125rem;
      margin: 0.875rem 0.875rem 0 0;
      position: relative;
      //标题
      .order-right-contend {
        font-size: 1rem;
        color: #1a1a1a;
      }
      //规格
      .order-right-gauge {
        font-size: 0.75rem;
        color: #999999;
        margin-top: 0.625rem;
      }
      .order-right-price {
        font-size: 1.125rem;
        color: #ff0000;
        position: absolute;
        bottom: 0;
      }
    }
  }
}
// 底部按钮
.dark-buttom {
  margin: 2.375rem auto;
  width: 21.5625rem;
  height: 3.0625rem;

  border-radius: 1.5625rem;
  font-size: 1.125rem;
  color: #ffffff;
  text-align: center;
  line-height: 3.0625rem;

  /* 设置渐变 */
  background: rgb(255, 0, 0); /* Old browsers */
  background: -moz-linear-gradient(
    to right bottom,
    rgb(255, 127, 95) 10%,
    rgb(229, 39, 77) 70%
  ); /* FF3.6-15 */
  background: -webkit-linear-gradient(
    to right bottom,
    rgb(255, 127, 95) 10%,
    rgb(229, 39, 77) 70%
  ); /* Chrome10-25,Safari5.1-6 */
  background: linear-gradient(
    to right bottom,
    rgb(255, 127, 95) 30%,
    rgb(229, 39, 77) 80%
  ); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff0000', endColorstr='#ffffff',GradientType=0 ); /* IE6-9 */
}
</style>
